package universe.forces;

import universe.CelestialBody;
import universe.utils.Vector3D;

public class GravityForce implements Force {

	public static final double G = 6.674E-11;

	@Override
	public Vector3D getInteractionForceBetween(CelestialBody p1,
			CelestialBody p2) {
		Vector3D gForce = new Vector3D();

		gForce.x = p2.getPosition().x - p1.getPosition().x;
		gForce.y = p2.getPosition().y - p1.getPosition().y;
		gForce.z = p2.getPosition().z - p1.getPosition().z;

		double k = (G * p1.getMass() * p2.getMass()) / Math.pow(gForce.mod(), 3);
		gForce.mult((float) k);
		
		return gForce;
	}
}
